/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package specifications;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.nodes.Tag;

/**
 *
 * @author Jason
 */
public class ProviderDirective extends Directive {
   public static final Tag TAG = new Tag("!ProviderDirective");
   
   
   public ProviderDirective(){super();}
   public ProviderDirective(String request){super(request);}
   public ProviderDirective(String request, int priority){super(request, priority);}
   
       @Override
    public void dump(String filename) throws IOException {
        Yaml yaml = new Yaml(CONSTRUCTOR, REPRESENTER);
        FileWriter writer = new FileWriter(filename);
        writer.write(yaml.dumpAs(this, TAG, DumperOptions.FlowStyle.BLOCK));
        writer.close();
        //System.out.println(yaml.dumpAs(this, TAG, DumperOptions.FlowStyle.BLOCK));
    }

    @Override
    public Directive load(String filename) throws IOException {
        Yaml yaml = new Yaml(CONSTRUCTOR, REPRESENTER);
        FileReader reader = new FileReader(filename);
        Directive dir = yaml.loadAs(reader, Directive.class);
        reader.close();
        return dir;
    }
   
}
